// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) ansi lnc 

package com.example.airkissdemo.logic;

import com.example.airkissdemo.MainActivity;
import com.example.airkissdemo.Util.Util;
import com.example.airkissdemo.core.BaseTaskDispatchThread;
import com.example.airkissdemo.core.IOnTaskEndCallback;
import com.example.airkissdemo.protocol.AirKissProtocol;

// Referenced classes of package com.example.airkissdemo.logic:
//            OnAirKissTaskEndCallback, AirKissTaskDispatchThread, AirKissTask

public class AirKissManager
{

    public AirKissManager(MainActivity mainactivity)
    {
        mMainActivity = mainactivity;
        mCallback = new OnAirKissTaskEndCallback(this);
        mDispatch = new AirKissTaskDispatchThread(mCallback);
        (new Thread(mDispatch)).start();
    }

    protected void finalize()
        throws Throwable
    {
        mDispatch.stop();
        super.finalize();
    }

    public void sendLogMsg(int i, Object obj, int j)
    {
        mMainActivity.sendLogMsg(i, obj, j);
    }

    public int startAirKiss(String s, String s1)
    {
        AirKissTask airkisstask;
        airkisstask = new AirKissTask(s, s1);
        mMainActivity.sendLogMsg(1, "original data:", 0);
        mMainActivity.sendLogMsg(1, Util.byteArray2HexString(airkisstask.mAirKiss.getOriData(), airkisstask.mAirKiss.getOriData().length), 0);
        mMainActivity.sendLogMsg(1, "magic code field:", 0);
        mMainActivity.sendLogMsg(1, Util.shortArray2HexString(airkisstask.mAirKiss.getMagicCode(), airkisstask.mAirKiss.getMagicCode().length), 0);
        mMainActivity.sendLogMsg(1, "prefix code field:", 0);
        mMainActivity.sendLogMsg(1, Util.shortArray2HexString(airkisstask.mAirKiss.getPrefixCode(), airkisstask.mAirKiss.getPrefixCode().length), 0);
        mMainActivity.sendLogMsg(1, "sequences field:", 0);
        mMainActivity.sendLogMsg(1, Util.shortArray2HexString(airkisstask.mAirKiss.getSequencesData(), airkisstask.mAirKiss.getSequencesData().length), 0);
        this;
        JVM INSTR monitorenter ;
        mIsStarted = true;
        this;
        JVM INSTR monitorexit ;
        startNextTask(airkisstask);
        return 0;
        Exception exception;
        exception;
        this;
        JVM INSTR monitorexit ;
        throw exception;
    }

    public int startNextTask(AirKissTask airkisstask)
    {
        this;
        JVM INSTR monitorenter ;
        boolean flag = mIsStarted;
        this;
        JVM INSTR monitorexit ;
        if(flag)
            mDispatch.startTask(airkisstask);
        return 0;
        Exception exception;
        exception;
        this;
        JVM INSTR monitorexit ;
        throw exception;
    }

    public void stopAirKiss()
    {
        this;
        JVM INSTR monitorenter ;
        mIsStarted = false;
        return;
    }

    private IOnTaskEndCallback mCallback;
    private BaseTaskDispatchThread mDispatch;
    private boolean mIsStarted;
    private MainActivity mMainActivity;
}
